#!/bin/bash
export 'PS4=[`date +"%Y-%m-%d %H:%M:%S"`]`basename $0`.$LINENO+'
set -x

source ../lib/lib.sh
source ../lib/repolib.sh
source ../lib/gitlib.sh
source ./config_obs_common.sh

if [ $# -lt 2 ]; then
    echo "Usage: $0 branch obs_project_list version"
    echo "example: $0 EulerOS_V2R2C20 EulerOS:2.2:ARM64:kernel@EulerOS:2.2:ARM64:update EulerOS_2.2.9-2018-07-16-10-06-29"
    exit 1
fi

meta_branch=$1
prjlist=$2
versionmsg=$3

check_obs_meta $meta_branch
set +e
repo_reversion_result=0
python repo_reversion.py -l $prjlist
if [ $? -ne 0 ]; then
    repo_reversion_result=1
fi
set -e
pushd $git_root/obs_meta
echo $versionmsg > README
popd
update_obs_meta $versionmsg $meta_branch
exit ${repo_reversion_result}
